# encoding: utf-8
# 项目名称： 常用设计模式
# @File  : 013-责任链模式.py
# @Author: sun hao
# @Desc : 
# @Date  :   20:14 2024/11/05
from abc import ABCMeta, abstractmethod


class Handler(metaclass=ABCMeta):
    @abstractmethod
    def handle_leave(self, day):
        pass


class GeneralManager(Handler):
    def handle_leave(self, day):
        if day <= 10:
            print(f'总经理批准{day}天假期')
        else:
            print(f'总经理说：{day}天假期太久出来，你还是提桶跑路吧')


class DepartmentManager(Handler):
    def __init__(self):
        self.next = GeneralManager()

    def handle_leave(self, day):
        if day <= 5:
            print(f'部门经理批准{day}天假期')
        else:
            print(f'{day}天假期太久了，部门经理批不了，往上报')
            self.next.handle_leave(day)


class ProjectDirector(Handler):
    def __init__(self):
        self.next = DepartmentManager()

    def handle_leave(self, day):
        if day <= 3:
            print(f'技术主管批准{day}天假期')
        else:
            print(f'{day}天假期太久了，技术主管批不了，往上报')
            self.next.handle_leave(day)


day = 4
user = ProjectDirector()
user.handle_leave(day)